package com.jin.controller;

import com.jin.config.MessageConfig.Message;
import com.jin.pojo.OrderDesc;
import com.jin.service.OrderDescService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "订单模块")
@RestController
@RequestMapping("/orderDesc")
@CrossOrigin
public class OrderDescController {
    @Autowired
    OrderDescService orderDescService;

    @ApiOperation(value = "添加订单")
    @PostMapping("/insertOrderDesc")
    public Message insertOrderDesc(OrderDesc orderDesc) {
        return orderDescService.insertOrderDesc(orderDesc)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }

    @ApiOperation(value = "删除订单")
    @DeleteMapping("/deleteOrderDesc")
    public Message deleteOrderDesc(int id) {
        return orderDescService.deleteOrderDesc(id)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }

    @ApiOperation(value = "更新订单")
    @PutMapping("/updateOrderDesc")
    public Message updateOrderDesc(OrderDesc orderDesc) {
        return orderDescService.updateOrderDesc(orderDesc)>0?Message.success("200").add("success"):Message.fail("400").add("fail");
    }

    @ApiOperation(value = "根据ID查订单")
    @GetMapping("/getOrderDescById")
    public Message getOrderDescById(int id) {
        return Message.success("200").add(orderDescService.getOrderDescById(id));
    }

    @ApiOperation(value = "查询全部订单")
    @GetMapping("/getOrderDescs")
    public Message getOrderDescs() {
        return Message.success("200").add(orderDescService.getOrderDescs());
    }

    @ApiOperation(value = "查询订单目前是否被审批")
    @GetMapping("/getOrderApproveStatus")
    public Message getOrderApproveStatus(Integer id) {
        return Message.success("200").add(orderDescService.getOrderApproveStatus(id));
    }

}
